#import "HelloThereViewController.h"
#import "URLLoader.h"


@implementation HelloThereViewController

- (void)viewDidLoad { 	
	locationController = [[MyCLController alloc] init];
	locationController.delegate = self;
	[locationController.locationManager startUpdatingLocation];
    
    
    
   [NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
    
    
    updateLabel=[[UILabel alloc]init];
    updateLabel.frame=CGRectMake(0,0,300, 50);
    
    [self.view addSubview:updateLabel];
    
    [updateLabel release];
}


- (void)receivedData:(NSData *)data withURL:(NSString*)url{
    NSLog(@"receivedData length---->%d",[data length]);
}

- (void)receiveDataFailedWithError:(NSError *)error withURL:(NSString*)url{
    NSLog(@"receiveDataFailedWithError---->%@",url);
}




- (void)onTimer {
    static int counter;
    
    //[viewController updateLabel];
    NSLog(@"xxxxxx%d",counter);
    
    counter++;
    
    updateLabel.text=[NSString stringWithFormat:@"---->%d",counter];
    
    
    URLLoader *myLoader=[[[URLLoader alloc]init]autorelease];
    NSLog(@"-->>>%@",locationLabel.text);
    [myLoader loadUrl:@"http://www.baidu.com" withDelegate:self];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; 
}

- (void)dealloc {
	[locationController release];
    [super dealloc];
}

- (void)locationUpdate:(CLLocation *)location {
	locationLabel.text = [location description];
}

- (void)locationError:(NSError *)error {
	locationLabel.text = [error description];
}

@end
